package com.zzx.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.zzx.entity.TProductGx;
import com.zzx.service.TProductGxService;
import com.zzx.entity.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品-工序表 控制器
 *
 * @author zzx
 * @since 2025-06-14
 */

@Api(tags = "产品-工序分组-工序 模块管理")
@RestController
@RequestMapping("/tProductGx")
public class TProductGxController {

    @Resource
    private TProductGxService tProductGxService;

    @ApiOperation(value = "新增、编辑")
    @PostMapping("/add")
    public ApiResult add(@RequestBody TProductGx param) {
        tProductGxService.add(param);
        return ApiResult.ok();
    }

    @ApiOperation(value = "批量新增")
    @PostMapping("/batchAdd")
    public ApiResult batchAdd(@RequestBody List<TProductGx> param) {
        tProductGxService.addBatch(param);
        return ApiResult.ok();
    }

    @ApiOperation(value = "列表查询")
    @PostMapping("/selectBy")
    public ApiResult selectBy(@RequestBody TProductGx param) {
        return ApiResult.ok(tProductGxService.selectBy(param));
    }

    @ApiOperation("根据ID获取详情")
    @GetMapping("/{id}")
    public ApiResult getById(@PathVariable("id") String id) {
        return ApiResult.ok(tProductGxService.findById(id));
    }

    @ApiOperation(value = "删除")
    @PostMapping("/deleteById")
    public ApiResult deleteById(@RequestBody TProductGx param) {
        tProductGxService.deleteById(param);
        return ApiResult.ok();
    }
}
